package com.zndroid.gridview.preview.indicator.impl;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zndroid.gridview.R;
import com.zndroid.gridview.preview.indicator.IIndicator;

/**
 * preview indicator of TextView like:
 * <code>2/7</code>
 *
 * @author lzy
 */
public class TextViewBgIndicator implements IIndicator {
    @Override
    public View bindView(LayoutInflater layoutInflater, ViewGroup root) {
        return layoutInflater.inflate(R.layout.layout_textview_bg_indicator, root, false);
    }

    @Override
    public void onIndex(View indicatorView, int position, int total) {
        if (indicatorView instanceof TextView) {
            ((TextView)indicatorView).setText(String.format(indicatorView.getContext().getString(R.string.txt_preview_bg_index), position + 1, total));
        }
    }

    @Override
    public int left() {
        return 0;
    }

    @Override
    public int top() {
        return 0;
    }

    @Override
    public int right() {
        return 0;
    }

    @Override
    public int bottom() {
        return 64;
    }

    @Override
    public int gravity() {
        return CENTER_BOTTOM;
    }
}
